﻿<script type="text/javascript">
    $(document).ready(function () {
        var p = new singlepage();
        p.c = "Way.Bus.WMS.ST.Controllers.InOrder.ReceiveNoticeController";
        p.applyTo = "t1";
        //p.showfooter = false;
        p.onCommandClick = function (command, form, item) {
            if (command == "add") {
                form.setform("STATE", "0");
            }
        }

        p.onForeigned = function (sender, fdata, rows) {

            if (sender.field == "CLIENTNO") {
                var from = sender.parent;
                var box1 = from.findbox("WORKERID");
                var box2 = from.findbox("BUMEN");
                var grid = from.findgrid("Way.Bus.WMS.Model.StockInNoticeMaterials");
                box1.clear();
                box2.clear();
                grid.clear();
            }
        }
        p.onGridAddOrEdit = function (grid, cmd, item, ischild) {
            if (ischild) {
                if (cmd == "add" || cmd == "edit") {
                    if (grid.parent) {
                        var box = grid.parent.findbox("ISSQE");
                        var val = box.val();
                        if (val == 1)
                            return true;
                        else
                            return false;
                    }
                }
            }
        }
        p.init();
    });

    function import2(data) {
        try {
            $('<div id="d2"><div id="d3"/></div>').appendTo($("#temp"));
            var p1 = new datasource();
            p1.c = "Way.Bus.WMS.ST.Controllers.ST_ExcelDRController";
            p1.applyTo = "d3";
            if (data && data.item) {
                var issubmit = data.item.ISSUBMITED;
                if (issubmit) {
                    $.messager.alert('提示', '预收单已提交，不能进行导入操作！', 'info');
                    return null;
                }
            } else {
                $.messager.alert('提示', '请选择一个预收单！', 'info');
                return null;
            }
            //限制主单导入显示
            data.sender.datasource.modeldata.nimport = true;
            window.ddata = data;
            window.pdata = p1;
            p1.init();
            $('#d2').dialog({
                title: "导入数据",
                collapsible: false,
                resizable: false,
                width: 700,
                height: 400,
                cache: false,
                href: "Views/manager/Exceldr.htm",
                onClose: function () {
                    $(this).panel('destroy');
                    $("#temp").empty();
                    window.ddata = null;
                }
            });
        } catch (e) {

        }
    }
    function emport2(data) {
        $('<div id="d2"><div id="d3"/></div>').appendTo($("#temp"));
        var p2 = new singlepage();
        p2.c = "Way.Bus.Controllers.ExcelDCController";
        p2.applyTo = "d3";
        //p1.outc = form.parent.c;
        //p1.ssss = data;
        window.ddata = data;
        window.pdata = p2;
        p2.init();
        $('#d2').dialog({
            title: "导出数据",
            collapsible: false,
            width: 400,
            height: 320,
            cache: false,
            href: p2.datasource.url,
            onClose: function () {
                $(this).panel('destroy');
                $("#temp").empty();
                window.ddata = null;
            }
        });
    }
</script>
<div id="t1"></div>
